package com.xc.model.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ResultDTO {
    private Integer code;
    private String msg;
    private Integer count;
    private Object data;

    public static ResultDTO error(String msg) {
        return data(-1, msg, 0, 0);
    }

    public static ResultDTO data(String msg) {
        return data(0, msg, 0, null);
    }

    public static ResultDTO data(int count) {
        return data(0, "", count, null);
    }

    public static ResultDTO data(Object data) {
        return data(0, "", 0, data);
    }

    public static ResultDTO data(int count, Object data) {
        return data(0, "", count, data);
    }

    public static ResultDTO data(String msg, Object data) {
        return data(0, msg, 0, data);
    }

    public static ResultDTO ok(Integer code, String msg, Object data) {
        return data(code, msg);
    }

    public static ResultDTO data(int code, String msg, int count, Object data) {
        return ResultDTO.builder()
                .code(code)
                .msg(msg)
                .data(data)
                .count(count)
                .build();
    }

}
